package org.lego.biz.task.management.base.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.lego.biz.task.management.base.entity.base.UUIDWithTimeAndStatusEntity;

import javax.persistence.*;
import java.util.List;

/**
 * Created by hr.qjy on 16/11/17.
 * 任务
 */
@Entity
@Table(name = "biz_task")
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
public class Task extends UUIDWithTimeAndStatusEntity {
    public static final String TASK_STATUS_NOTSTART = "-1"; // 任务未开始
    public static final String TASK_STATUS_NORMAL = "0"; // 任务进行中
    public static final String TASK_STATUS_FINISH = "1"; // 任务完成
    public static final String TASK_STATUS_STOP = "2"; // 任务停止
    public static final String TASK_TYPE_NORMAL = "0";   // 任务类型: 一般任务
    public static final String TASK_TYPE_INVENTORY = "1";// 任务类型: 清单任务
    private String name;        // 任务名称
    private Integer endTime;    // 截止时间
    @Lob
    private String description; // 任务描述(文本编辑器)
    @Lob
    private String comment;     // 任务评论
    private String taskStatus = TASK_STATUS_NOTSTART;      // 任务状态
    private String type;        // 任务类型

    @ManyToOne
    @JoinColumn(name = "module_id")
    @JsonIgnore
    private TaskModule taskModule;

    @OneToMany
    @JoinColumn(name = "task_id")
    private List<TaskCheckPoint> checkPoints;  // 检查项(外键,单向一对多)
}
